import os
from langchain_openai import OpenAIEmbeddings
from langchain_huggingface import HuggingFaceEmbeddings
from config.settings import settings


def get_embedding_model():
    """
    获取嵌入模型
    返回HuggingFaceEmbeddings实例
    """
    # 配置环境变量
    os.environ['HF_HUB_DISABLE_SYMLINKS_WARNING'] = '1'
    # 设置国内镜像源
    os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
    return HuggingFaceEmbeddings(
        model_kwargs={"trust_remote_code": True},
        encode_kwargs={
            "normalize_embeddings": True,
            "batch_size": 2
        },
        model_name="BAAI/bge-small-zh-v1.5",#"BAAI/bge-large-zh-v1.5",
        cache_folder = "./model_cache"  # 指定模型缓存目录
    )



